import { registerMicroApps, start } from 'qiankun'
import { loading } from '../store'

export const registerApp = list => {
  // 注册到微前端框架里
  registerMicroApps(list, {
    beforeLoad: [
      () => {
        loading.changeLoading(true)
        console.log('开始加载')
      }
    ],
    beforeMount: [
      () => {
        console.log('挂载前')
      }
    ],
    // mounted: [
    //   () => {
    //     loading.changeLoading(false)
    //     console.log('渲染完成')
    //   }
    // ],
    afterMount: [
      () => {
        loading.changeLoading(false)
        console.log('挂载后')
      }
    ],
    // destoryed: [
    //   () => {
    //     console.log('卸载完成')
    //   }
    // ],
    afterUnmount: [
      () => {
        console.log('卸载后')
      }
    ]
  })

  start()
}
